<template>
  <div class="content">
    <!--    数据字典公共列表弹窗-->
    <el-dialog
      v-dialogDrag
      :title="$t('market.infoList')"
      model
      :visible.sync="isclientlDialog"
      :close-on-click-modal="false"
      width="60%"
      :before-close="handleClose"
    >
      <jc-table
        :table-data="tableData"
        :table-header="tableHeader"
        table-height="53vh"
        serial
        @clickRow="clientlSelectRow"
      />
    </el-dialog>
  </div>
</template>
<script>
import { queryViewItem } from '@/api/marketManage/marketOrder'

export default {
  props: {
    msg: {
      type: String,
      default: ''
    }
  },
  data() {
    return {
      isclientlDialog: true,
      tableData: [],
      tableHeader: [
        { label: this.$t('market.dataName'), prop: 'fname' },
        { label: this.$t('shop.fnumber'), prop: 'fnumber' },
        { label: this.$t('market.descrip'), prop: 'fdescripTion' },
        { label: this.$t('shop.type'), prop: 'typeName' }
      ],
      prodValue: { fcustId: '', fname: '', isclientlDialog: true }
    }
  },
  created() {
    this.getBasicUnit()
  },
  methods: {
    // 基本单位
    async getBasicUnit() {
      const DATA = { viewName: this.msg, isAll: this.msg === 'SX_V_BASEUNIT' ? 1 : 0 }
      const { data: RES } = await queryViewItem(DATA)
      this.tableData = RES.list
    },
    // 单位选中
    clientlSelectRow(item) {
      this.prodValue = item
      this.$emit('unit', this.prodValue)
    },
    // 关闭前回调
    handleClose() {
      this.prodValue.isclientlDialog = false
      this.$emit('unit', this.prodValue)
    }
  }
}
</script>

<style scoped lang="scss">
.content {
  @include listBom;
}
</style>
